using UnityEngine;

public class PlayerListItem : MonoBehaviour
{
	public UILabel indexLabel;

	public UISprite flagSprite;

	public UILabel nameLabel;

	protected PlayerDB.TournamentPlayer player;

	public void Init(PlayerDB.TournamentPlayer player, int index)
	{
		this.player = player;
		indexLabel.text = index.ToString();
		GameConstants.SetFlag(flagSprite, (int)player.flag);
		nameLabel.text = player.playerName;
	}

	public void OnClick()
	{
		MatchParameters.MatchParams matchParams = MatchParameters.MatchParams.CreateDefault();
		GGPlayerSettings instance = GGPlayerSettings.instance;
		matchParams.player1Name = instance.GetName();
		matchParams.player1Flag = instance.Model.flag;
		matchParams.player2Name = player.playerName;
		matchParams.player2Flag = (int)player.flag;
		matchParams.pointsToWinGame = 11;
		matchParams.gamesToWinMatch = 1;
		matchParams.opponentDefinition = player;
		BehaviourSingleton<ScreenNavigation>.instance.LoadTableTennisMatch(matchParams);
	}
}
